<template>
    <div class="container" ref="container">
        <div id="mindMapContainer"></div>
    </div>
</template>

<script>
import MindMap from 'simple-mind-map'
export default {
    name: 'YourComponentName',
    mounted() {
        this.mindMap = new MindMap({
            el: document.getElementById('mindMapContainer'), //容器元素
            theme: 'earthYellow', //主题设计，需引入相关插件
            draggable: true, //是否可拖拽
            data: this.flowData //思维导图数据
        })
    },

    data() {
        return {
            mindMap: null, // 思维导图实例
            flowData: {
                data: {
                    text: '根节点', //展示的名称
                    id: '111' //可添加任意参数
                },
                children: [
                    {
                        data: {
                            text: '子1节点',
                            id: '112'
                        },
                        children: []
                    },
                    {
                        data: {
                            text: '子2节点',
                            id: '113'
                        },
                        children: []
                    }
                ]
            }
        }
    }
}
</script>

<!-- 样式设计 -->
<style lang="less" scoped>
.container {
    position: relative;
    width: 100%;
    height: 100vh;
}

#mindMapContainer {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-y: hidden;
}
</style>
